package cn.com.api.mapper.base;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.*;

import cn.com.api.entity.ApiU_discover_cate;

//DAO
public interface U_discover_cateMapperBase {

	// 根据id查看
	@Select("SELECT * FROM U_DISCOVER_CATE  WHERE ID = #{id}")
	public ApiU_discover_cate findU_discover_cateById(Integer id);

	// 查看数据集
	@Select("SELECT * FROM U_discover_cate")
	public List<ApiU_discover_cate> findU_discover_cates();

	// 根据条件查看数据集
	public List<Map<String, Object>> findU_discover_catesByMap(HashMap condition);

	// 添加
	@Insert("INSERT INTO U_DISCOVER_CATE (PARENT_ID, CATE_NAME, CATE_DESC, SORT, TYPE) VALUES (#{parent_id}, #{cate_name}, #{cate_desc}, #{sort}, #{type})")
	@Options(useGeneratedKeys = true, keyProperty = "id")
	public int insertU_discover_cate(ApiU_discover_cate u_discover_cate);

	// 修改
	@Update("UPDATE U_DISCOVER_CATE SET PARENT_ID = #{parent_id}, CATE_NAME = #{cate_name}, CATE_DESC = #{cate_desc}, SORT = #{sort}, TYPE = #{type} WHERE ID = #{id}")
	public int updateU_discover_cate(ApiU_discover_cate u_discover_cate);

	// 删除
	@Delete("DELETE FROM U_DISCOVER_CATE  WHERE ID = #{id}")
	public int deleteU_discover_cate(Integer id);

	// Foreign keys revelant

	// region Indexs revelant

	// 根据type类型获得新发现分类
	@Select("SELECT * FROM U_DISCOVER_CATE WHERE TYPE= #{type}  order by SORT")
	public List<ApiU_discover_cate> findU_discover_cates_by_type(Integer type);

}
